// PLEASE COMMENT YOUR JS WELL
$(function(){

	$('#slideshow-images li:first-child').addClass('start first');
	$('#slideshow-images li:last-child').addClass('last');
	$('#slideshow-bullets li:last-child').addClass('bulletActive');
	// Loop through the list and fade/show each banner.
	var startSlide='';
	function slider(){
		startSlide = setInterval(function(){
			$('li.start').fadeOut(1000, function(){ $(this).removeClass('start'); });
			$('li.bulletActive').removeClass('bulletActive').prev().addClass('bulletActive');
			if($('li.start').hasClass('last')){
				$('li.first').fadeIn(1000).addClass('start');
				$('#slideshow-bullets li:last-child').addClass('bulletActive');
			}else{
				$('li.start').next().fadeIn(1000).addClass('start');
			}
		}, 5000);
	}
	// Catch button clicks to stop our slider.
	$('#slideshow-bullets li').click(function(){
		clearInterval(startSlide);
		// Get the image to fade in based on id from disc li and fade the current one out.
		var id = $(this).attr('id').split('-');
		id = id[1];
		$('#slideshow-images li').removeClass('start').fadeOut(1000);
		$('#slideshow-images li#slide-'+id).addClass('start').fadeIn(1000);
		// Clear the current disc and set the appropriate one active.
		$('#slideshow-bullets li').removeClass('bulletActive');
		$(this).addClass('bulletActive');
		// Wait 1/2 a second and then start the slider up again.
		setTimeout(function(){ 
			slider(); 
		}, 500);
	});
	// Call our slider function to get it going.
	slider(); 	
	
	// Home page category buttons
	$(".category-buttons")
		.mouseenter(function(){
			if ( $(this).hasClass("category-wound") ){
				y = 265;
			} else if ( $(this).hasClass("category-safety") ){
				y = 226;	
			} else if ( $(this).hasClass("category-design") ){
				y = 245;	
			}
			$(this).children(".category-slide-links-wrapper").stop(true, true).animate({height: y}, 300);
			$("#category-buttons-wrapper").animate({height: 300}, 300);
			if ( typeof wait != 'undefined' ){
				clearTimeout(wait);
			}
		})
		.mouseleave(function(){
			$(this).children(".category-slide-links-wrapper").animate({height: '104'}, 300);
			wait = setTimeout(function(){
			    $("#category-buttons-wrapper").animate({height: 200}, 300);
			}, 3000);
		});								
		
	// Home page footer tweak - set #bg-logo to display none to suck the footer toward the top
	if ( $(".template-home").length ){
		$("#bg-logo").css("display", "none");
	}

	
	// Product specification table striping
	if ( $(".product-specifications").length ){
		$(".product-specifications table").each(function(){
			$(this).find("tr").filter(":even").addClass("striped");												 
		});
	}

});

// PLACE CUSTOM FUNCTIONS HERE















